package com.yunhe.mybatis.web.person;

import com.yunhe.mybatis.entity.Deparment;
import com.yunhe.mybatis.entity.User;
import com.yunhe.mybatis.service.DeparmentService;
import com.yunhe.mybatis.service.UserService;
import com.yunhe.mybatis.service.impl.DeparmentServiceImpl;
import com.yunhe.mybatis.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/person/p/update")
public class Update extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //从list页面中拿的数据 带入到
        Integer parameter = Integer.valueOf(req.getParameter("itemId"));

        UserService userService = new UserServiceImpl();
        //注意这块查全部数据
        User user = userService.find(parameter);
        req.setAttribute("user",user);


        req.getRequestDispatcher("/WEB-INF/person/update.jsp").forward(req,resp);
    }
}
